package com.yunxiangyue

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.util.Log
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.yunxiangyue.app.R

class framlayoutActivity : AppCompatActivity() {
    val mine = mine_fragement.newInstance()
    val recommend = recommend_fragement.newInstance()
    val msg = msg_fragement.newInstance()
    val focus = focus_fragement.newInstance()
    val community = community_fragement.newInstance()
    lateinit var mHandler: Handler
    private lateinit var phone:String
    private var bundle:Bundle? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_framlayout)
        val actionBar=supportActionBar
        if(actionBar!=null){
//            设置ActionBar是否显示返回键
            actionBar.setDisplayHomeAsUpEnabled(false)
//            设置是否显示标题
            actionBar.setDisplayShowTitleEnabled(false)
        }

        phone = intent.getStringExtra("phone").toString()
        mine.setParams(phone)
        Log.d("ning",phone.toString())
//        getId()
        supportFragmentManager.beginTransaction().add(R.id.frame,mine).commit()
        val bottom = findViewById<BottomNavigationView>(R.id.bottom)
        bottom.itemIconTintList=null
        bottom.setOnItemSelectedListener {
            when(it.itemId){
                R.id.community->supportFragmentManager.beginTransaction()
                    .replace(R.id.frame,community).commit()
                R.id.focus -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame,focus).commit()
                R.id.mine -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame,mine).commit()
                R.id.recommend -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame,recommend).commit()
                R.id.msg -> supportFragmentManager.beginTransaction()
                    .replace(R.id.frame,msg).commit()
            }
            true
        }
        actionBar?.hide()


    }




    fun getId(){
        val bun = intent.extras
        val fragementFlag = bun?.getString("fragementFlag")?.toInt()
        if(fragementFlag == 0){
            supportFragmentManager.beginTransaction()
                .replace(R.id.frame,mine)
                .addToBackStack(null)
                .commit()
        }
    }


    open fun setHandler(handler: Handler) {
        mHandler = handler
    }
}